package hflyeer.o2o.biz.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import hflyeer.o2o.biz.service.ProductCategoryService;
import hflyeer.o2o.model.dao.ProductCategoryDao;
import hflyeer.o2o.model.entity.ProductCategory;

@Service("ProductCategoryService")
public class ProductCategoryServiceImpl implements ProductCategoryService {
	
	@Autowired
	private ProductCategoryDao produtCategoryDao;

	@Override
	public List<ProductCategory> queryForProductCategory(ProductCategory productCategoryCondition) {
		return produtCategoryDao.queryForList(productCategoryCondition);
	}

	@Override
	@Transactional
	public int batchInsert(List<ProductCategory> list) {
		for (ProductCategory productCategory : list) {
			if(productCategory.getPriority()==null) {
				productCategory.setPriority(0);
			}
			productCategory.setCreateTime(new Date());
		}
		return produtCategoryDao.batchInsert(list);
	}

	@Override
	public int delete(Integer id) {
		return produtCategoryDao.delete(id);
	}

}
